package facade.facade_role;

import facade.subsystem.CPU;
import facade.subsystem.HardDisk;
import facade.subsystem.Memory;
import facade.subsystem.OS;

public class Mainframe {
    private final CPU cpu;
    private final HardDisk hardDisk;
    private final Memory memory;
    private final OS os;

    public Mainframe(){
        cpu = new CPU();
        hardDisk = new HardDisk();
        os = new OS();
        memory = new Memory();
    }
    public void on(){
        if(!cpu.run()){
            System.out.println("主机启动失败!原因:CPU运行出错");
            return;
        }
        if(!memory.check()){
            System.out.println("主机启动失败!原因:内存自检出错");
            return;
        }
        if(!hardDisk.read()){
            System.out.println("主机启动失败!原因:硬盘读取错误");
            return;
        }
        if(!os.load()){
            System.out.println("主机启动失败!原因:系统加载出错");
            return;
        }
        System.out.println("主机启动成功!");
    }
}
